From: Owen Taylor Date: Tue, 20 Jan 2009 18:32:25 +0000 (+0000) Subject: Adapt to new Tweener frame ticker API X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~11486 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=ff5f960978c42a92e62092b273174bf9f51c40a0;p=gnome-shell.git Adapt to new Tweener frame ticker API Now that getTime() has been added to the frame ticker interface we can implement frame dropping in a more straightforward way than adjusting the FRAME_RATE member variable to fool Tweener into doing the right thing. svn path=/trunk/; revision=156 --- diff --git a/js/ui/main.js b/js/ui/main.js index fef838aee..18ade8b81 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -37,13 +37,14 @@ function ClutterFrameTicker() { } ClutterFrameTicker.prototype = { - TARGET_FRAME_RATE : 60, + FRAME_RATE : 60, _init : function() { // We don't have a finite duration; tweener will tell us to stop // when we need to stop, so use 1000 seconds as "infinity" - this._timeline = new Clutter.Timeline({ fps: this.TARGET_FRAME_RATE, + this._timeline = new Clutter.Timeline({ fps: this.FRAME_RATE, duration: 1000*1000 }); + this._currentTime = 0; this._frame = 0; let me = this; @@ -76,13 +77,18 @@ ClutterFrameTicker.prototype = { delta = frame - this._frame; if (delta == 0) // protect against divide-by-0 if we get a frame twice - this.FRAME_RATE = this.TARGET_FRAME_RATE; - else - this.FRAME_RATE = this.TARGET_FRAME_RATE / delta; + delta = 1; + + // currentTime is in milliseconds + this._currentTime += (1000 * delta) / this.FRAME_RATE; this._frame = frame; this.emit('prepare-frame'); }, + getTime : function() { + return this._currentTime; + }, + start : function() { this._timeline.start(); }, @@ -90,6 +96,7 @@ ClutterFrameTicker.prototype = { stop : function() { this._timeline.stop(); this._frame = 0; + this._currentTime = 0; } };